/**
 * 全局 状态器
 */

// 测试示例
import {
    Test
} from 'http/global';

export default {
    namespaced: true,
    state: {
        count: 6,
        exampleMsg: '你好呀'
    },
    mutations: {
        TestM() {
            Test();
        },
        increment (state) {
            state.count++;
        }
    },
    actions: {
        incrementIfOddOnRootSum ({ state, commit, rootState }) { // 对于模块内部的 action，局部状态通过 context.state 暴露出来，根节点状态则为 context.rootState
            if ((state.count + rootState.count) % 2 === 1) {
              commit('increment');
            }
        }
    },
    getters: {
        sumWithRootCount (state, getters, rootState) {
            return state.count + rootState.count;
        }
    }
};
